home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / misc / unix / tracker_4_3.lzh / tracker / analyzer.c next >
Encoding:
C/C++ Source or Header  |  1994-02-13  |  3.4 KB  |  176 lines

  1. /* analyzer.c 
  2.     vi:set ts=3 sw=3:
  3. */
  4.  
  5.  
  6. /* read module files and output statistics on them */
  7.  
  8. /* $Id: analyzer.c,v 4.1 1994/01/12 16:10:20 espie Exp espie $
  9.  * $Log: analyzer.c,v $
  10.  * Revision 4.1  1994/01/12  16:10:20  espie
  11.  * Fixed up last minute problems.
  12.  *
  13.  * Revision 4.0  1994/01/11  17:38:49  espie
  14.  * Lots of changes.
  15.  *
  16.  * Revision 1.5  1994/01/09  17:36:22  Espie
  17.  * Generalized open.c.
  18.  *
  19.  * Revision 1.4  1994/01/08  03:55:43  Espie
  20.  * removed create_note_tables(), run_in_fg().
  21.  *
  22.  * Revision 1.3  1994/01/06  22:32:42  Espie
  23.  * Use new pref scheme.
  24.  *
  25.  * Revision 1.2  1994/01/05  14:54:09  Espie
  26.  * *** empty log message ***
  27.  *
  28.  * Revision 1.1  1993/12/26  00:55:53  Espie
  29.  * Initial revision
  30.  *
  31.  * Revision 3.3  1993/12/04  16:12:50  espie
  32.  * BOOL -> boolean.
  33.  * New open_file semantics.
  34.  *
  35.  * Revision 3.2  1993/05/09  14:06:03  espie
  36.  * Added speed check.
  37.  *
  38.  * Revision 3.1  1993/01/16  17:00:27  espie
  39.  * Added patch for non termio.
  40.  *
  41.  * Revision 3.0  1992/11/18  16:08:05  espie
  42.  * New release.
  43.  *
  44.  */
  45.  
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49.  
  50. #include "defs.h"
  51. #include "extern.h"
  52. #include "song.h"
  53. #include "tags.h"
  54. #include "prefs.h"
  55.  
  56. ID("$Id: analyzer.c,v 4.1 1994/01/12 16:10:20 espie Exp espie $")
  57.  
  58. int error;
  59.  
  60. struct song *do_read_song(name, type)
  61. char *name;
  62. int type;
  63.    {
  64.    struct song *song;
  65.    struct exfile *file;
  66.  
  67.    file = open_file(name, "r", getenv("MODPATH"));
  68.    if (!file)
  69.       return NULL;
  70.    song = read_song(file, type); 
  71.    close_file(file);
  72.    if (song)
  73.       puts(name);
  74.    return song;
  75.    }
  76.  
  77.  
  78. boolean use_command[16];
  79. boolean use_extended[16];
  80.  
  81. void analyze_block(b)
  82. struct block *b;
  83.    {
  84.    int i, j;
  85.    struct event *e;
  86.  
  87.    for (i = 0; i < BLOCK_LENGTH; i++)
  88.       {
  89.       int special;
  90.  
  91.       special = 0;
  92.       for (j = 0; j < NUMBER_TRACKS; j++)
  93.          {
  94.          e = &b->e[j][i];
  95.          switch(e->effect)
  96.             {
  97. #if 0
  98.          case 13: /* skip */
  99.             return;
  100.          case 11: /* fastskip */
  101.             return;
  102. #endif
  103.          case 14:
  104.             use_extended[HI(e->parameters)] = TRUE;
  105.             break;
  106.          case 15:
  107.             if (special != 0 && e->parameters != special)
  108.                putchar('!');
  109.             else
  110.                special = e->parameters;
  111.          default:
  112.             use_command[e->effect] = TRUE;
  113.             }
  114.          }
  115.       }
  116.    }
  117.  
  118.  
  119. void analyze_song(song)
  120. struct song *song;
  121.    {
  122.    int i;
  123.  
  124.    for (i = 0; i < NUMBER_SAMPLES; i++)
  125.       {
  126.       if (song->samples[i].start)
  127.          {
  128.          if (song->samples[i].finetune)
  129.             printf("Sample %d: finetune is %d\n", 
  130.                i, song->samples[i].finetune);
  131.          }
  132.       }
  133.    for (i = 0; i < 16; i++)
  134.       {
  135.       use_command[i] = FALSE;
  136.       use_extended[i] = FALSE;
  137.       }
  138.    for (i = 0; i < song->info.maxpat; i++)
  139.       analyze_block(song->info.pblocks+i);
  140.    for (i = 0; i < 16; i++)
  141.       if (use_command[i])
  142.          printf("%3d", i);
  143.    for (i = 0; i < 16; i++)
  144.       if (use_extended[i])
  145.          printf("%3dE", i);
  146.    printf("\n");
  147.    }
  148.  
  149. int main(argc, argv)
  150. int argc;
  151. char **argv;
  152.    {
  153.    int i;
  154.  
  155.    struct song *song;
  156.    int default_type;
  157.  
  158.    default_type = BOTH;
  159.    set_pref_scalar(PREF_TOLERATE, 2);
  160.  
  161.    for (i = 1; i < argc; i++)
  162.       {
  163.       song = do_read_song(argv[i], NEW);
  164.       if (!song && error != NEXT_SONG)
  165.          song = do_read_song(argv[i], OLD);
  166.       if (song)
  167.          {
  168.          analyze_song(song);
  169.          release_song(song);
  170.          }
  171.       }
  172.    }
  173.  
  174.  
  175.  
  176.